<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>摊位信息管理</title>
    <%@ include file="../inc.jsp" %>
  </head>
  
  <body class="easyui-layout">
    <div data-options="region:'north',border:false" style="height:50px; overflow:hidden;padding:0px">
        <form action="" method="post" id="searchForm">
           <div style="margin-left:10px; margin-top:10px;">
				摊位名称:&nbsp;<input class="easyui-validatebox textbox" id="name" name="name" maxlength="100" style="width:160px">&nbsp;&nbsp;&nbsp;
				摊位编号:&nbsp;<input class="easyui-validatebox textbox" id="num" name="num" maxlength="100" style="width:160px">&nbsp;&nbsp;&nbsp;
               	状态:&nbsp;<select id="status">
                        <option value="">请选择</option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>&nbsp;&nbsp;&nbsp;
				<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="find()">查询</a>
			</div>
        </form>  
    </div>
    <div data-options="region:'center',border:false">
	   <table id="dg" class="easyui-datagrid" title="摊位信息列表" fit="true" style="width:700px;height:250px"
			data-options="rownumbers:true,singleSelect:true,url:'${baseUrl }/admin/booth/list',method:'post',toolbar:'#toolbar',
			showFooter:false,pagination:true,idField:'id'">
		<thead>
			<tr>
				<th data-options="field:'name',width:100">摊位名称</th>
				<th data-options="field:'num',width:100">编号</th>
				<th data-options="field:'area',width:200">占地面积</th>
				<th data-options="field:'address',width:300">地址</th>
				<th data-options="field:'status',width:80,align:'center',formatter:showStatus" >摊位状态</th>
				<th data-options="field:'create_time',width:150">创建时间</th>
				<th data-options="field:'creator_name',width:150">创建人</th>
			</tr>
		</thead>
	   </table>
        <!-- 功能菜单 -->
        <div id="toolbar" style="display: none;" align="left">
            <a href="javascript:void(0);" class="easyui-linkbutton"data-options="iconCls:'icon-add',plain:true" onclick="add_fun();" id="add">添加</a>
            <a href="javascript:void(0);" class="easyui-linkbutton"data-options="iconCls:'icon-edit',plain:true" onclick="edit_fun();" id="update">修改</a>
            <a href="javascript:void(0);" class="easyui-linkbutton"data-options="iconCls:'icon-remove',plain:true" onclick="delete_fun();" id="delete">删除</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="open_disable_fun(1);">启用</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="open_disable_fun(0);">禁用</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="reset_fun();">清空条件</a>
            <script type="text/javascript">
            function add_fun()
            {
                var params = {
                        winId:'win_add_both',
                        title:'添加摊位',
                        width:800,
                        height:390,
                        showUrl:'${baseUrl}/admin/booth/au_page',
                        refresh_fun:function(){
                            $('#dg').datagrid('reload');
                        }
                        
                };
                open_fun(params);
            }
            function edit_fun()
            {
                var selectId = 0;
                var row = $('#dg').datagrid('getSelected');
                if(row)
                {
                	selectId = row.id;
                }
                if(selectId>0)
                {
                    //winId,title,width,height,showUrl,okUrl,refresh_fun
                    var params = {
                            winId:'win_edit_booth',
                            title:'修改摊位信息',
                            width:800,
                            height:390,
                            showUrl:'${baseUrl}/admin/booth/au_page?selectId='+selectId,
                            refresh_fun:function(){
                                $('#dg').datagrid('reload');
                            }
                            
                    };
                    open_fun(params);   
                }
                else
                {
                    $.messager.alert("提示","请选择要修改的信息!",'info');
                }
            }
            function delete_fun()
            {
                var row = $('#dg').datagrid('getSelected');
                if(!row)
                {
                    $.messager.alert("提示","请选择要删除的数据！",'info');
                }
                else
                {
                    $.messager.confirm("删除确认","是否要删除你选择的数据？",function(conf){
                        if(conf)
                        {
                            var url = "${baseUrl}/admin/booth/delete?selectId="+row.id;
                            $.getJSON(url, function(json){
                                if(json.success==0)
                                {
                                	$('#dg').datagrid('reload');
                                }
                                else
                                {
                                    showErrMsg(json);
                                }
                            });
                        }                                       
                    });
                }
                
            }
            function open_disable_fun(flag)
            {
                var row = $('#dg').datagrid('getSelected');
                if(!row)
                {
                    $.messager.alert("提示","请选择一条记录！",'info');
                }
                else
                {
                    $.messager.confirm("确认","是否要操作你选择的数据？",function(conf){
                        if(conf)
                        {
                            var url = "${baseUrl}/admin/booth/doOpen?selectId="+row.id+"&status="+flag;
                            $.getJSON(url, function(json){
                                if(json.success==0)
                                {
                                	$('#dg').datagrid('reload');
                                }
                                else
                                {
                                    showErrMsg(json);
                                }
                            });
                        }                                       
                    });
                }
                
            }
            function find()
    		{
    			$('#dg').datagrid('load',{
    				name:$('#name').val(),
    				num:$('#num').val(),
    				status:$('#status').val()
    			});
    		}
            function reset_fun(){
            	$('#searchForm').form('reset');
            	find();
            }
            </script>
    </div>
  	
  	</div>
    <script type="text/javascript">
    	$('#reg_time').datetimebox({
                showSeconds:false
                //formatter: formatDateText,
                //parser: parseDate
            });
    	function showStatus(value,rec,index)
    	{
    		if(value==0)
    			return "<font color='red'>禁用</font>";
    		else
    			return "<font color='green'>启用</font>";
    	}
    	
	</script>
  </body>
</html>
